-
Notifications
You must be signed in to change notification settings - Fork 1
/
CGPA - Grade to Points calculation (swtich case).java
52 lines (51 loc) · 1.4 KB
/
CGPA - Grade to Points calculation (swtich case).java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import java.util.Scanner;
class cgpa_GradeToPoints_SwitchCase {
public static void main(String args[]){
Scanner input = new Scanner(System.in);
System.out.print("Enter the obtained grade: ");
String grade = input.nextLine();
double points;
switch (grade) {
case "A+":
points = 4.00;
break;
case "A":
points = 3.75;
break;
case "A-":
points = 3.50;
break;
case "B+":
points = 3.25;
break;
case "B":
points = 3.00;
break;
case "B-":
points = 2.75;
break;
case "C+":
points = 2.50;
break;
case "C":
points = 2.25;
break;
case "D":
points = 2.00;
break;
case "F":
points = 0.00;
break;
default:
points = -1;
break;
}
if(points == -1){
System.out.println("Invalid grade");
}else if(points == 0.00){
System.out.printf("\nResult Failed \nPoints: %.2f", points);
}else{
System.out.printf("\nResult Passed \nPoints: %.2f", points);
}
}
}